{% extends "bills/base.html" %}
{% block body_main %}
<table border="0">
<tr>
<td valign="top">
<table border="1">
<caption>  Счет: </caption>
<tbody>
 <tr> <th> # </th> <td> {{ object.pk }} </td> </tr>
 <tr> <th> Объект </th> <td> {{ object.project }} </td> </tr>
 <tr> <th> Направление </th> <td> {{ object.depart }} </td> </tr>
 <tr> <th> Поставщик </th> <td> {{ object.supplier }} </td> </tr>
 <tr> <th> Ответственный </th> <td> {{ object.assign.get_fio }} </td> </tr>
 <tr> <th> Подписант </th> <td> {% if object.rpoint %} {{ object.rpoint }} {% else %} --- {% endif %} </td> </tr>
 <tr> <th> Состояние </th> <td> {{ object.get_state_name }} </td> </tr>
 <tr> <th> Маршрут </th> <td>
  <ol style="margin: 0">
  {% for i in object.route_set.all %}
   <li> <p style="margin: 0{% if i.order < object.rpoint.order %}; text-decoration: line-through{% endif %}"> {{ i.get_str }} </p> </li>
  {% endfor %}
  </ol>
 </td> </tr>
 <tr>
  <td> Оригинал: </td>
  <td> <ol style="margin: 0">
   {% for img in object.fileseq.fileseqitem_set.all %}
    <li>
     <a href="{% url core.views.file_get img.pk %}" data-lightbox="roadtrip" title="{{ img.file.name }}">{{ img.file.name }}</a>
     <!--a href="#" onClick="window.open('{% url core.views.file_get img.pk %}', '_blank', 'toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0, width=500, height=500');return(false)"> <img src="{{ STATIC_URL }}img/png_16x16.png" title="{{ img.file.name }}"/> </a-->
     <a href="{% url core.views.file_get img.pk %}"> <img src="{{ STATIC_URL }}img/png_16x16.png" title="Download"/> </a>
    </li>
   {% endfor %}
  </ol> </td>
 </tr>
 </tbody>
</table>
</td>
<td valign="top">
<table border="1">
<caption> История: </caption>
<thead>
 <th> Ok </th>
 <th> Когда </th>
 <th> Кто </th>
 <th> Камменты </th>
</thead>
<tbody>
  {% for i in object.events.all %}
  <tr>
   <td valign="top"> <img {% if i.resume %} src="{{ STATIC_URL }}img/dialog-ok.png" title="OK" {% else %} src="{{ STATIC_URL }}img/dialog-cancel.png" title="Canceled" {% endif %} width="16px" height="16px"/> </td>
   <td valign="top"> {{i.ctime|date:"y.m.d H:i:d" }} </td>
   <td valign="top"> {{ i.approve.get_fio }} </td>
   <td valign="top"> <pre style="margin: 0"> {{ i.comment }} </pre> </td>
  </tr>
  {% endfor %}
</tbody>
</table>
</td>
</tr>
</table>
<p>
{% if canarch %}	<a href="{% url bills.views.bill_toscan object.pk %}"> {% include "button/arch.html" %} </a> {% endif %}
{% if canedit %}	<a href="{% url bills.views.bill_edit object.pk %}"> {% include "button/edit.html" %} </a> {% endif %}
{% if candel %}		<a href="{% url bills.views.bill_delete object.pk %}"> {% include "button/delete.html" %} </a> {% endif %}
{% if canrestart %}	<a href="{% url bills.views.bill_restart object.pk %}"> {% include "button/restart.html" %} </a> {% endif %}
{% if user.is_superuser %}
<a href="{% url bills.views.mailto object.pk %}"> {% include "button/mailto.html" %} </a>
{% endif %}
</p>
{% if canaccept %}
<form action="" method="POST">
	{% csrf_token %}
	{{ form.as_p }}
<p> <i> (комментарий обязателен только при Отказе) </i> </p>
<p>
{% if object.rpoint %}
<button type="submit" name="resume" value="accept" style="padding: 10px; background-color: chartreuse">
{% if canreject %}
 Согласовано
{% else %}
 {% if object.done %}
  Исполнено
 {% else %}
  В оплате
 {% endif %}
{% endif %}
</button>
{% if canreject %}
<button type="submit" name="resume" value="reject" style="padding: 10px; background-color: red"> Отказать </button>
{% endif %}
{% else %}
<button type="submit" name="resume" value="accept"> Вперед </button>
{% endif %}
</p>
</form>
{% endif %}
{% if err %} <p> Error: {{ err }} </p> {% endif %}
{% endblock %}
